package cn.phantom.interrrupt;

import java.util.concurrent.TimeUnit;

public class InterruptTest01 {

    static volatile boolean isStop = false;

    public static void main(String[] args) {
        new Thread(() -> {
            while (true) {
                if (isStop) {
                    System.out.println("-----isStop = true, 程序结束");
                    break;
                }
                System.out.println("------hello isStop");
            }
        }, "t1").start();

        try {
            TimeUnit.MILLISECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(() -> {
            isStop = true;
        }, "t2").start();


    }
}
